/*
 * author      : dormi330
 * date        : 2018/6/26
 * description : 订单item
 */

package com.deep.trade.domain.order;


import com.deep.trade.common.BaseEntity;

import java.math.BigDecimal;

public class TradeOrderSku extends BaseEntity {
    private String tradeOrderId;                //交易订单id

    private String sellerId;                    //卖家
    private String sellerName;                  //卖家名称
    private String shopId;                      //商铺信息
    private String itemId;                      //item信息
    private String itemName;                    //此item的名称
    private String itemCode;                    //此item的编号
    private String skuId;                       //sku id
    private String skuCode;                     //sku code
    private String imgUrl;                      //图片地址
    private String brandId;                     //品牌id
    private int quantity;                       //购买数量
    private String propNames;                   //属性名, 多值, 逗号分隔
    private String propValues;                  //属性值
    private BigDecimal commission;              //分润

    // 金额相关的信息
    private BigDecimal priceMoney;              //sku价格

    private BigDecimal skuDiscountMoney;        //sku级优惠额度
    private BigDecimal shopDiscountMoney;       //sku级优惠额度
    private BigDecimal platformDiscountMoney;   //平台优惠
    private BigDecimal freightMoney;            //运费金额
    private BigDecimal itemMoney;               //订单所有商品的商品金额小计 ,运算得来
    private BigDecimal payMoney;                //实付金额, 运算得来


    /**
     * - 计算商品金额小计
     * - 计算实际价格
     */
    public void calculateMoney() {
        // 商品总额 = 单价 * 数量
        this.itemMoney = this.priceMoney.multiply(new BigDecimal(this.quantity));

        // 实付 = 商品总额 + 运费 - (各种折扣只和)
        this.payMoney = this.itemMoney
                .add(this.freightMoney)
                .subtract(this.skuDiscountMoney)
                .subtract(this.shopDiscountMoney)
                .subtract(this.platformDiscountMoney);

        // 如果小于0, 则置为0
        this.payMoney = this.payMoney.compareTo(BigDecimal.ZERO) == -1 ? BigDecimal.ZERO : this.payMoney;
    }

    public TradeOrderSku() {
        super();
    }

    // === setter / getter ===


    public String getItemCode() {
        return itemCode;
    }

    public void setItemCode(String itemCode) {
        this.itemCode = itemCode;
    }

    public String getPropNames() {
        return propNames;
    }

    public void setPropNames(String propNames) {
        this.propNames = propNames;
    }

    public String getPropValues() {
        return propValues;
    }

    public void setPropValues(String propValues) {
        this.propValues = propValues;
    }

    public BigDecimal getCommission() {
        return commission;
    }

    public void setCommission(BigDecimal commission) {
        this.commission = commission;
    }

    public String getImgUrl() {
        return imgUrl;
    }

    public void setImgUrl(String imgUrl) {
        this.imgUrl = imgUrl;
    }

    public String getSellerName() {
        return sellerName;
    }

    public void setSellerName(String sellerName) {
        this.sellerName = sellerName;
    }

    public BigDecimal getPayMoney() {
        return payMoney;
    }

    public void setPayMoney(BigDecimal payMoney) {
        this.payMoney = payMoney;
    }

    public BigDecimal getSkuDiscountMoney() {
        return skuDiscountMoney;
    }

    public void setSkuDiscountMoney(BigDecimal skuDiscountMoney) {
        this.skuDiscountMoney = skuDiscountMoney;
    }

    public BigDecimal getShopDiscountMoney() {
        return shopDiscountMoney;
    }

    public void setShopDiscountMoney(BigDecimal shopDiscountMoney) {
        this.shopDiscountMoney = shopDiscountMoney;
    }

    public BigDecimal getPlatformDiscountMoney() {
        return platformDiscountMoney;
    }

    public void setPlatformDiscountMoney(BigDecimal platformDiscountMoney) {
        this.platformDiscountMoney = platformDiscountMoney;
    }

    public BigDecimal getFreightMoney() {
        return freightMoney;
    }

    public void setFreightMoney(BigDecimal freightMoney) {
        this.freightMoney = freightMoney;
    }

    public BigDecimal getItemMoney() {
        return itemMoney;
    }

    public void setItemMoney(BigDecimal itemMoney) {
        this.itemMoney = itemMoney;
    }

    public String getTradeOrderId() {
        return tradeOrderId;
    }

    public void setTradeOrderId(String tradeOrderId) {
        this.tradeOrderId = tradeOrderId;
    }

    public String getSellerId() {
        return sellerId;
    }

    public void setSellerId(String sellerId) {
        this.sellerId = sellerId;
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String shopId) {
        this.shopId = shopId;
    }

    public String getItemId() {
        return itemId;
    }

    public void setItemId(String itemId) {
        this.itemId = itemId;
    }

    public String getSkuId() {
        return skuId;
    }

    public void setSkuId(String skuId) {
        this.skuId = skuId;
    }

    public BigDecimal getPriceMoney() {
        return priceMoney;
    }

    public void setPriceMoney(BigDecimal priceMoney) {
        this.priceMoney = priceMoney;
    }

    public String getBrandId() {
        return brandId;
    }

    public void setBrandId(String brandId) {
        this.brandId = brandId;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public String getSkuCode() {
        return skuCode;
    }

    public void setSkuCode(String skuCode) {
        this.skuCode = skuCode;
    }

    public String getItemName() {
        return itemName;
    }

    public void setItemName(String itemName) {
        this.itemName = itemName;
    }
}
